<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"/>
    <link rel="stylesheet" href="css/base.css"/>
    <link rel="stylesheet" href="css/style.css"/>
    <title>参与活动赢大奖</title>
    <div id='wx_pic' style='margin:0 auto;display:none;'>
        <img src='./img/pic300.jpg'/>
    </div>
</head>
<body>
<div class="chouJBox">
    <div class="choujBtn"></div>
    <div class="chouJCont">
            <div class="chouJContOne">
                <h5>口令红包 : <span id="Code">欢乐五一华质检测豪礼相送</span></h5>
                <div class="Resultbtn">
                    <a href="./index.html"><img src="./img/gohome1.png" alt=""/></a>
                </div>
            </div>
            <div class="chouJContTwo">
                <div class="usercall">
                    <input type="text" id="inpVal" placeholder="请先输入您的电话号码"/>
                </div>
                <div class="Resultbtn">
                    <a href="javascript:;" id="maxCode"><img src="./img/gohome1.png" alt=""/></a>
                </div>
            </div>
            <div class="chouJContFail">
                <div class="Resultbtn">
                    <a href="./index.html"><img src="./img/gohome1.png" alt=""/></a>
                </div>
            </div>
            <div class="chouJContFail3">
                <div class="Resultbtn">
                    <a href="./index.html"><img src="./img/gohome1.png" alt=""/></a>
                </div>
            </div>
    </div>
</div>
<script type="application/javascript" src="js/zepto.min.js"></script>
<script type="application/javascript" src="js/zepto-touch.js"></script>
<script type="application/javascript" src="js/fastclick.js"></script>
<script type="application/javascript" src="js/script.js"></script>
<script type="application/javascript">
    document.body.addEventListener('touchstart', function () {
    });
    $(function(){
        $('.choujBtn').on('tap',function(){
            $('.chouJCont').show();
            $.ajax({
                type: "get",
                url: 'https://wx.weiqiangtech.com/lotterydraw/start',
                success: function (data) {
                    if(data.result==3){
                        $('.chouJContFail').show();//没抽中
                        return;
                    }else if(data.result==2){
                        $('.chouJContTwo').show();//抽大奖了
                        return;
                    }else if(data.result==1){
                        $('.chouJContOne').show();//抽红包了
                        $('#Code').html(data.msg)
                        return;
                    }else if(data.result==4){
                        $('.chouJContFail3').show();//超过三次抽奖
                    }
                },
                error:function () {
                    alert("请求失败！");
                }
            });
        })

        $('#maxCode').on('tap',function(){
            $.ajax({
                type: "get",
                url: 'http://123.124.202.227/lotterydraw/phone',
                data:{'phone':$('#inpVal').val()},
                success: function (data) {
                    if(data.code==1000){
                        window.location.href="./index.html";
                    }
                },
                error:function () {
                    alert("存入失败，请重新提交！");
                }
            });
        })

    })

</script>
</body>
</html>